package com.tdf.webblog.handler;

import com.tdf.webblog.api.MySQLRemoteService;
import com.tdf.webblog.dto.UserDTO;
import com.tdf.webblog.result.Result;
import com.tdf.webblog.result.ResultFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class UserHandler {

    @Autowired
    private MySQLRemoteService mySQLRemoteService;

    @GetMapping("/admin/user")
    public Result listUsers() {
        List<UserDTO> userDTOList = mySQLRemoteService.listRemote();
        return ResultFactory.buildSuccessResult(userDTOList);
    }
}
